<template>
  <div class="my-container">
    <div class="top-box">
      <div class="user-box">
        <div class="info-box">
          <span class="first">{{ userInfo.nickname }}</span>
          <span class="last">{{ userInfo.intro }}</span>
        </div>
        <van-image
          class="avatar"
          :src="userInfo.avatar"
          round
          fit="cover"
          @click="toEdit"
        />
      </div>
      <div class="data-box">
        <div class="item">
          <span class="num">304</span>
          <span class="select">复答题</span>
        </div>
        <div class="item">
          <span class="num">2</span>
          <span class="select">收藏题目</span>
        </div>
        <div class="item">
          <span class="num">56</span>
          <span class="select">我的错题</span>
        </div>
        <div class="item">
          <span class="num">23%</span>
          <span class="select">正确率</span>
        </div>
      </div>
    </div>
    <van-cell
      title="我的岗位"
      class="role iconfont iconicon_mine_gangwei"
      :value="userInfo.position"
      is-link
      to="/gangwei"
    />
    <div class="main">
      <div class="experience-box">
        <div class="title">面经数据</div>
        <div class="chart-items">
          <div class="item">
            <div class="top">
              昨日阅读
              <span>+{{ userInfo.shareData.read.yesterday }}</span>
            </div>
            <div class="num">{{ userInfo.shareData.read.total }}</div>
            <div class="bottom">阅读总数</div>
          </div>
          <div class="item">
            <div class="top">
              昨日获赞
              <span>+{{ userInfo.shareData.star.yesterday }}</span>
            </div>
            <div class="num">{{ userInfo.shareData.star.total }}</div>
            <div class="bottom">获赞总数</div>
          </div>
          <div class="item">
            <div class="top">
              昨日新增
              <span>+{{ userInfo.shareData.comment.yesterday }}</span>
            </div>
            <div class="num">{{ userInfo.shareData.comment.total }}</div>
            <div class="bottom">评论总数</div>
          </div>
        </div>
      </div>

      <van-cell
        title="我的面经分享"
        class="iconfont iconicon_mine_mianjing"
        value="21"
        is-link
      />
      <van-cell
        title="我的消息"
        class="iconfont iconicon_mine_xiaoxi"
        value="98"
        is-link
        to="/message"
      />
      <van-cell
        title="收藏的题库"
        class="iconfont iconicon_mine_tikushoucang"
        value="32"
        is-link
      />
      <van-cell
        title="收藏的企业"
        class="iconfont iconicon_mine_qiyeshoucang"
        value="43"
        is-link
      />
      <van-cell
        title="我的错题"
        class="iconfont iconicon_mine_qiyeshoucang"
        value="123"
        is-link
      />
      <van-cell
        title="收藏的面试经验"
        class="iconfont iconicon_mine_cuoti"
        value="166"
        is-link
      />
    </div>
  </div>
</template>

<script>
// import { userInfoAPI } from '@/api'
// import { mapActions } from 'vuex'

export default {
  data () {
    return {}
  },
  async created () {
    this.$store.dispatch('user/getUserInfo')
  },
  computed: {
    userInfo () {
      return this.$store.state.user.userInfo
    }
  },
  // created () {
  //   this.getUserInfo()
  // },
  methods: {
    // ...mapActions('user', ['getUserInfo']),

    toEdit () {
      this.$router.push({
        path: '/edit'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.my-container {
  font-size: 14px;
  height: 700px;
  .top-box {
    height: 216px;
    background-image: linear-gradient(45deg, #ce0031 0%, #b8002c 100%);
    .user-box {
      display: flex;
      justify-content: space-between;
      padding-top: 28px;
      align-items: center;
      padding-left: 20px;
      padding-right: 30px;
      font-size: 16px;
      .avatar {
        width: 40px;
        height: 40px;
        border: 5px solid #c7697e;
      }
      .info-box {
        height: 40px;
        width: 145px;
        .first {
          font-size: 20px;
          font-weight: 600;
        }
        .last {
          display: block;
          font-size: 12px;
          color: #eba5b5;
        }
      }
    }
    .data-box {
      display: flex;
      justify-content: space-around;
      margin-top: 30px;
      color: rgb(232, 230, 227);
      .item {
        width: 50px;
        height: 43px;
        text-align: center;
        .num {
          font-size: 20px;
          font-weight: 600;
          display: block;
        }
        .select {
          font-size: 12px;
          color: #d0a1a9;
        }
      }
    }
  }
  .role {
    position: absolute;
    top: 180px;
    left: 13px;
    width: 351px;
    border-radius: 10px;
  }
  .main {
    .experience-box {
      width: 310px;
      height: 140px;
      padding: 20px 18px 0;
      border-radius: 8px;
      margin-bottom: 16px;
      margin: auto;
      .title {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 16px;
      }
      .chart-items {
        display: flex;
        align-items: center;
        justify-content: space-around;
        .item {
          text-align: center;
          .top {
            font-size: 10px;
            font-weight: 400;
            color: #c5c5cc;
            span {
              color: #3bc8dd;
            }
          }
          .num {
            margin: 8px 0;
            font-size: 20px;
            font-weight: 600;
          }
          .bottom {
            color: #61627b;
            font-weight: 400;
            font-size: 12px;
          }
        }
      }
    }
  }
}
</style>
